package Unicart.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

public class OrderAdminPage extends AnyPage {

	public OrderAdminPage(PageManager pages) {
		super(pages);
	}

	@FindBy (xpath ="//*[@id='filternumber']")
	private WebElement idInput;
	
	@FindBy (xpath ="//td[1]/table/tbody/tr[2]/td/input[@onclick and @type='button' and @value='Найти']")
	private WebElement searchButton;
	
	public OrderAdminPage ensurePageLoaded() {
	    super.ensurePageLoaded();
	    wait.until(presenceOfElementLocated(By.xpath("//*[@id='filternumber']")));
	    return this;
	  }
	
	public OrderAdminPage setIdInput(String id) {
	    idInput.sendKeys(id);
	    return this;
	  }
	
	public OrderAdminPage clickSearchButton() {
		searchButton.click();
		return this;
	  }
	
	public OrderAdminPage checkId(String id) {
		wait.until(presenceOfElementLocated(By.xpath("//b[.='"+id+"']")));
		return this;
	}
	
}
